package com.zygh.policeasset.service;

import com.zygh.policeasset.mapper.ApprovalStepsMapper;
import com.zygh.policeasset.mapper.UserMapper;
import com.zygh.policeasset.pojo.ApprovalSteps;

import java.util.List;

import com.zygh.policeasset.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class ApprovalStepsService {
    @Autowired
    ApprovalStepsMapper approvalStepsMapper;

    @Autowired
    UserMapper userMapper;

    public List<ApprovalSteps> selectAll(String type) {

        List<ApprovalSteps> selectAll = this.approvalStepsMapper.selectAll(type);

    /*    for (int i = 0; i < selectAll.size(); i++) {
            String name = "";
            if (!StringUtils.isEmpty(selectAll.get(i).getApprovedBy())) {
                String[] strings = selectAll.get(i).getApprovedBy().split(",");
                for (int j = 0; j < strings.length; j++) {
                    System.out.println(strings[j]);
                    User u = userMapper.findUserById(Integer.parseInt(strings[j]));
                    if (j == strings.length - 1) {
                        name = name + u.getName();
                    } else {
                        name = name + u.getName() + "-";
                    }
                }
            }
            selectAll.get(i).setApprovedByName(name);
            name = "";
        }*/
        return selectAll;
    }
}